<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<%@taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<%@taglib uri="http://java.sun.com/jsp/jstl/sql" prefix="sql"%>

<!-- Authors: Mareike, David -->

<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<link href="style.css" rel="stylesheet" type="text/css" />

<title>Welcome to the Moss Street Market</title>
</head>
<body>
<body>
	<div class="main">
		<div class="header">
			<div class="header_resize">
				<div class="logo">
					<h1>
						<span>MossStreet</span>Market <small>Organic food,
							pottery, clothing ... just for you</small>
					</h1>
				</div>
				<div class="clr"></div>
				<div class="menu_nav">
					<ul>
						<li><a href="index.html">Home</a></li>
						<li class="active"><a href="Login.jsp">Login</a></li>
						<li><a href="index.html">Contact Us</a></li>
						<li><a href="index.html">Impressum</a></li>
					</ul>
				</div>
				<div class="clr"></div>
			</div>
		</div>
		<div class="content">
			<div class="content_resize">
				<div class="mainbar">
					<div class="article">
						<h2>
							<span>Welcome!</span>
						</h2>
						<div class="clr"></div>
						<c:choose>
							<c:when test="${empty cookie}">
								<jsp:forward page="Login.jsp" />
							</c:when>
							<c:otherwise>
								<!--  if the mossStreetMarketCookie has been set but the username is not in the session object -->
								<c:forEach var="cookieVal" items="${cookie}">
									<c:if test="${cookieVal.key == 'mossStreetMarketCookie'}">
										<c:if test="${empty sessionScope.username}">
											<jsp:forward page="Login.jsp" />
										</c:if>
									</c:if>
								</c:forEach>
							</c:otherwise>
						</c:choose>

						<c:if test="${stallnotavailable == 'true'}">
							<p>
								The stall <font color="blue" size="5">${stall_number}</font> is
								not available on <font color="blue" size="5">${marketday}</font>.
								<br> Please select another stall.
							</p>
						</c:if>


						<H3>
							Welcome to Moss Street Market,
							<c:out value="${username}" />
							!
						</H3>
						<p>Please proceed to Book a Stall by selecting a date and a
							stall.</p>
						<p>Alternately, if you wish to know which stalls are available
							on a specific date, pick a date and leave the stall unspecified.
						</p>
						<p>Or if you want to know on which dates a particular stall is
							available, pick the stall and leave the date unset.</p>

						<%@page import="com.moss.street.market.DerbyDatabase"%>
						<%@page import="java.sql.Connection"%>
						<%@page import="com.moss.street.market.StallsBean"%>

						<%
							Connection conn = DerbyDatabase.getConnInstance();
							StallsBean sb[] = DerbyDatabase.stallsList(conn);
						%>

						<form action="CheckBookingsServlet" method="post">

							<table width="100%">
								<tr>
									<td valign="top"><b>Reservation Date(s): </b><br> 
									<jsp:include
											page="/MarketDaysServlet">
											<jsp:param name="type" value="" />
										</jsp:include></td>

									<td><b>Pick A Stall: </b><br> 
									<select
										name="stall_number" size="10">
											<%
												if (sb != null) {
													for (int i = 0; i < sb.length; i++) {
											%>
											<option value="<%=sb[i].getStallNumber()%>">
												<%
													if (i < 9) {
												%>
												<%="&nbsp;"%>
												<%
													}
												%>
												<%=sb[i].getStallNumber() + "&nbsp;&nbsp; $"
							+ sb[i].getFee() + "&nbsp;&nbsp; "
							+ sb[i].getWidth() + "cm*" + sb[i].getLength()
							+ "cm &nbsp;&nbsp;" + sb[i].getStallType()%>
											</option>
											<%
												}
												}
											%>
									</select></td>
								</tr>
							</table>
							<br> <br></br> <input type="submit" name="submit">
						</form>

						<br> <br>
						<form method="post" action="index.html">
							<hr>
							Otherwise click on Cancel and return to the Home page.<br> <input
								type="hidden" name="stallnotavailable" value="false" /> <input
								type="hidden" name="loggedOut" value="true" /> <input
								type="submit" name="Select New Stall" value="Cancel"><br>
							<br>
						</form>
					</div>
				</div>

				<div class="sidebar">
					<div class="gadget">
						<div class="clr"></div>
						<img src="images/logo.jpg" alt="Moss Street Market Logo">
					</div>

					<div class="gadget">
						<h2 class="star">
							<span>Location</span>
						</h2>
						<div class="clr"></div>
						Open Saturdays from <b>10am to 2pm</b><br> <br> 1330
						Fairfield Rd<br> Victoria, BC V8S 5J1, Canada<br>
						(250)361-1747<br> <br> Located at the corner of Moss
						Street and Fairfield Road in the Sir James Douglas school yard.
					</div>
				</div>

				<div class="clr"></div>
			</div>
		</div>
		<div class="footer">
			<div class="footer_resize">
				<p class="lf">
					Copyright &copy; 2011 <a href="http://www.mosssolutions.wordpress.com">moSSSolutions</a> - All Rights
					Reserved
				</p>
				<p class="rf">
					Your web-based application provided by <a
						href="http://www.mosssolutions.wordpress.com">moSSSolutions</a>
				</p>
				<div class="clr"></div>
			</div>
		</div>
	</div>
</body>
</html>

